﻿#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QTcpSocket>
#include <QTimer>

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

private slots:
    void onReadMessage();   //处理服务端反馈的数据
    void onDisplayError(QAbstractSocket::SocketError e);    //打印错误信息


    void on_pB_connect_clicked();

    void on_pB_send_clicked();

    void on_pB_disconnect_clicked();
    void onConnected();
    void onError(QAbstractSocket::SocketError);
    void onTimeout();


private:
    Ui::MainWindow *ui;
    QTcpSocket* m_tcpSocket = nullptr;    //tcp客户端
    QTimer *timer;
    void mInsertTextBycolor(Qt::GlobalColor color, QString str);
};
#endif // MAINWINDOW_H
